package com.fengye.netflix.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author sky
 * @date 2021/4/27 0:06
 */
@RestController
@RequestMapping("/consumer")
public class ConsumerMessageController {

    @Autowired
    private RestTemplate restTemplate;

    /**
     * 通过 eureka.instance.instance-id访问,而不能通过eureka.instance.appname访问
     * @return
     */
    @GetMapping("/message")
    public String getMessage() {
        System.out.println("message");
        String result = restTemplate.getForObject("http://cloud-provider-8001/message/hello?name=test", String.class);
        return result;
    }


}
